package com.os.lambda.chapter4;

import com.os.lambda.chapter3.StringLine;

import java.util.Optional;

public class Chapter4 {

    public static void main(String[] args) {

        Parent parent = new ParentImpl();
        parent.welcome();

        System.out.println(StringLine.STRING_LINE);

        Child child = new ChildImpl();
        child.welcome();

        System.out.println(StringLine.STRING_LINE);

        Parent parent1 = new OverridingParent();
        parent1.welcome();

        System.out.println(StringLine.STRING_LINE);

        Child child1 = new OverridingChild();
        child1.welcome();

        System.out.println(StringLine.STRING_LINE);

        Optional<String> a = Optional.of("a");
        System.out.println(a.get());

        System.out.println(StringLine.STRING_LINE);

        Optional emptyOptional = Optional.empty();
        Optional alsoEmpty = Optional.ofNullable(null);
        System.out.println(emptyOptional.isPresent());
        System.out.println(alsoEmpty.isPresent());
        System.out.println(a.isPresent());

        System.out.println(emptyOptional.orElse("b"));
        System.out.println(emptyOptional.orElseGet(()->
                "c"
        ));

    }

}
